import seckillApi from "@/api/declaration/mall/seckillApi"
import httpRequest from "@/config/axios/httpRequest"
import { SeckillConfigModel } from "@/models/mall/SeckillConfigModel"

// 秒杀时段 API
export const SeckillConfigApi = {
  // 查询秒杀时段分页
  getSeckillConfigPage: async (params: any) => {
    return await httpRequest.get(seckillApi.GetSeckillConfigPage, { params })
  },

  // 查询秒杀时段列表
  getSimpleSeckillConfigList: async () => {
    return await httpRequest.get(seckillApi.GetSimpleSeckillConfigList)
  },

  // 查询秒杀时段详情
  getSeckillConfig: async (id: number) => {
    return await httpRequest.get(seckillApi.GetSeckillConfig, { params: { id } })
  },

  // 新增秒杀时段
  createSeckillConfig: async (data: SeckillConfigModel) => {
    return await httpRequest.post(seckillApi.CreateSeckillConfig, data)
  },

  // 修改秒杀时段
  updateSeckillConfig: async (data: SeckillConfigModel) => {
    return await httpRequest.put(seckillApi.UpdateSeckillConfig, data)
  },

  // 删除秒杀时段
  deleteSeckillConfig: async (id: number) => {
    return await httpRequest.delete(seckillApi.DeleteSeckillConfig, { params: { id } })
  },

  // 修改时段配置状态
  updateSeckillConfigStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return httpRequest.put(seckillApi.UpdateSeckillConfigStatus, data)
  }
}
